<link href="${rc.getContextPath()}/manage/css/dwzCustomCss/dwz.custom.css?v=${ver}" rel="stylesheet" type="text/css">
<form method="post" action="${rc.getContextPath()}/manage/role/saveRole" class=" pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone);">
    <div class="pageContent">
        <div class="pageFormContent">
            <fieldset>
                <input type="hidden" name="navTabId" value="${navTabId!''}"> <input type="hidden" name="id" value="<#if (role.roleCode)??>${role.roleCode!''}</#if>"> <input type="hidden" id="user" name="user" value="${user!''}"> <input type="hidden" id="menu" name="menu" value="${menu!''}">
                <dl class="nowrap">
                    <div style="float: left; height: 25px; width: 300px;">
                        <label style="width: 60px"><@label key="roleCode.C,colon">角色编码：</@label></label> <input class="required alphanumeric toUp" name="roleCode" value="<#if (role.roleCode)??>${role.roleCode!''}</#if>" size="20" type="text" maxlength="40"<#if (role.roleCode)??> readonly="readonly"<#else> remote="${rc.getContextPath()}/manage/role/validateRoleCode"</#if> warn="<@label key="roleCodeExist.M">角色编号已经存在</@label>"/>
                    </div>
                    <div style="float: left; height: 25px; width: 300px;">
                        <label style="width: 60px"><@label key="roleText.C,colon">角色描述：</@label></label> <input class="required" name="roleText" value="<#if (role.roleText)??>${role.roleText!''}</#if>" size="20" type="text" maxlength="60" />
                    </div>
                </dl>
                <dl class="nowrap">
                    <dd>
                        <div class="tabs" currentIndex="0" eventType="click" style="width: 615px">
                            <div class="tabsHeader">
                                <div class="tabsHeaderContent">
                                    <ul>
                                        <li><a href="javascript:;"><span><@label key="detail.C">详情</@label></span> </a>
                                        </li>
                                        <li><a href="javascript:;"><span><@label key="user.C">用户</@label></span> </a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                            <div class="tabsContent">
                                <div style="height: 243px">
                                    <div style="float: left;">
                                        <label style="width: 55px"><@label key="memo.C,colon">备注：</@label></label>
                                        <textarea style="height: 120px; width: 520px;" name="memo" cols="68" rows="8"><#if (role.memo)??>${role.memo!''}</#if></textarea>
                                    </div>
                                    <p>
                                        <label style="width: 60px">&nbsp;</label> <label><input type="checkbox" name="lockFlag" value="1"<#if (role.lockFlag)?? && (role.lockFlag == 1)> checked="true"</#if>><@label key="lock.C">锁定</@label></label>
                                    </p>
                                    <p>
                                        <label style="width: 60px">&nbsp;</label> <label><input type="checkbox" name="systemFlag" value="1"<#if (role.systemFlag)?? && (role.systemFlag == 1)> checked="true"</#if>><@label key="systemFlag.C">系统内置角色</@label></label>
                                    </p>
                                </div>
                                <div style="height: 243px">
                                    <div id="bar" class="pBar">
                                        <ul class="toolBar">
                                            <input id="uid" type="hidden" name="uLookup.id" type="text" />
                                            <input id="uname" type="hidden" name="uLookup.name" type="text" />
                                            <li><a class="add" width="640" height="500" href="${rc.getContextPath()}/manage/role/selectUser?navTabId=${navTabId!''}" lookupGroup="uLookup" callback="u_callback" title="<@label key='addUser.C'>新增用户</@label>"><span><@label key="add.B">新增</@label></span> </a></li>
                                            <li><a href="javascript:" class="delete" onclick="userdel()"><span><@label key="delete.B">删除</@label></span> </a></li>
                                        </ul>
                                    </div>
                                    <table class="table border" width="100%" <#if (role.roleCode)??>layoutH="275"<#else>layoutH="205"</#if>>
                                        <thead>
                                            <tr>
                                                <th width="20"><input type="checkbox" group="ids" class="checkboxCtrl"></th>
                                                <th width="100"><@label key="userCode.C">用户编号</@label></th>
                                                <th width="100"><@label key="userText.C">用户名称</@label></th>
                                            </tr>
                                        </thead>
                                        <tbody id="utbody">
                                            <#if users??><#if (users?size>0)> <#list users as user>
                                            <tr id="user_${user.userCode!''}" target="user_code" rel="${user.userCode!''}">
                                                <td width="20"><input type="checkbox" name="ids" class="checkboxCtrl" value="${user.userCode!''}"></td>
                                                <td width="100">${user.userCode!''}</td>
                                                <td width="100">${user.userText!''}</td>
                                            </tr>
                                            </#list>
                                            </#if> 
                                            </#if>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            <div class="tabsFooter">
                                <div class="tabsFooterContent"></div>
                            </div>
                        </div>
                    </dd>
                </dl>
            </fieldset>
        </div>
        <#if (role.roleCode)??> <#assign createInfo=role/> <#include "/common/createInfo.html"> </#if>
        <div class="formBar">
            <ul>
                <li><div class="buttonActive" id="save">
                        <div class="buttonContent">
                            <button type="submit" onclick="c()"><@label key="save.B">保存</@label></button>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="buttonActiveGrey">
                        <div class="buttonContent">
                            <button type="button" class="close"><@label key="cancel.B">取消</@label></button>
                        </div>
                    </div></li>
            </ul>
        </div>
    </div>

</form>



<script type="text/javascript">
var $p=$.pdialog.getCurrent();
function u_callback() {
    var id = $("#uid").val();
    var name = $("#uname").val();
    var idArr = new Array();
    var nameArr = new Array();
    idArr = id.split(',');
    nameArr = name.split(',');
    var ht = "";
    for ( var i = 0; i < idArr.length; i++) {
        var userid = idArr[i];
        var username = nameArr[i];
        var my_element = $("#user_" + userid,$p);
        if (my_element.length == 0) {
            ht += "<tr id='user_"+userid+"'target='user_code' rel='"+userid+"'><td width='12'><input  name='ids' value='"+userid+"' type='checkbox'></td><td width='100'>"
                    + userid
                    + "</td><td width='100'>"
                    + username
                    + "</td></tr>";
        }

    }
    $("#utbody").append(ht);

}

function userdel() {
    var count = 0;
    $('input[name="ids"]:checked',$p).each(function(i, e) {
        count++;
    });
    if (count == 0) {
        alertMsg.warn('<@label key="selectUser.M">请勾选用户！</@label>')
    } else {
        alertMsg.confirm("<@label key="delUser.M">确定要删除选中的用户吗？</@label>", {
            okCall : function() {
                $('input[name="ids"]:checked').each(function(i, e) {
                    $("#user_" + e.value).remove();
                });
            }
        });
    }
}
function c() {
    var user = "";

    var usertable = $("#utbody");
    usertable.find("tr").each(function(i, n) {
        var obj = $(n)
        user += obj.attr("id").replace("user_", "") + ",";
    });
      
    if (user.length > 1) {
        user = user.substring(0, user.length - 1);
    }
    $("#user").val(user);
}
</script>
